package fr.pud.client.controller.query;

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import fr.pud.client.model.PUDStation;
import fr.pud.client.view.QueryFrame;

/**
 * Apr 14, 2012 - Projet_Ose.
 * @author Simon Devineau, Adrien Hierry, Leopold Houdin, Pierre Reliquet
 *         Ecole des Mines de Nantes
 *         ItemListennerForPickUp.java
 */
public class ItemListennerForPickUp implements ItemListener {
    /*
     * (non-Javadoc)
     * @see
     * java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
     */
    @Override
    public void itemStateChanged(ItemEvent aE) {
        PUDStation itemSelected = null;
        if (aE.getStateChange() == ItemEvent.SELECTED) {
            if (aE.getItem() instanceof PUDStation) {
                itemSelected = (PUDStation) aE.getItem();
                QueryFrame.getInstance().getDataPanel()
                        .getTextOpeningTimePickup()
                        .setText(itemSelected.getOpening().toString());
                QueryFrame.getInstance().getDataPanel()
                        .getTextClosingTimePickup()
                        .setText(itemSelected.getClosing().toString());
                QueryFrame.getInstance().getDataPanel()
                        .getTextLoadingTimePickUp()
                        .setText("" + itemSelected.getLoadingTime());
            }
        }
    }
}
